﻿using System.Runtime.Serialization;
using Game.Objects;
using Game.ResourceLocator;
using Game.Types;
using Game.Map.Extensions;

namespace Game.Command.Internal
{
    [DataContract(Namespace = "game")]
    public class BuildUnitAbility : GameAbility
    {
        readonly string _VehicleUrl;

        public BuildUnitAbility()
        {
            _VehicleUrl = "vehicle:Shock Trooper";
        }

        public static string URL
        {
            get { return "ability://BuildUnit"; }
        }

        public override string Url
        {
            get { return URL; }
        }

        public override SchedulerCommand GetCommand()
        {
            var obj = MapField.ObjectX().GameObject;
            if (obj == null)
            {
                return null;
            }

            var building = obj.Building as GameBuilding;
            if (building == null)
            {
                return null;
            }

            var v = GameResourceLocator.Get(_VehicleUrl) as VehicleType;
            var cmd = new BuildUnitScheduler(building, this.GameMap);

            return cmd;
        }

    }
}
